<?php
//数据库配置参数
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "dictionary";
 
// 创建连接
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("连接失败: " . $conn->connect_error);
} 

//获取客户端的成语
$word = $_GET['word'];

//SQL语句 
$sql = "SELECT * FROM cy WHERE name LIKE '".$word."' limit 1";
$result = $conn->query($sql);

//如果查到有数据
if ($result->num_rows > 0) {
    // 输出数据
    while($row = $result->fetch_assoc()) {
        $msg['result']=$row;
		$msg['code'] = 1;
    }
} else {
    $msg['result']="没查到！";
	$msg['code'] = 0;
}
//关闭数据库连接
$conn->close();

echo json_encode($msg);
?>